const posts = [
    { title: 'a', author: 'me', id: 0 },
    { title: 'b', author: 'she', id: 1 },
    { title: 'c', author: 'he', id: 2 },

]
function getPostById(id) {
    const post = posts.find((post) => post.id === id)
    /* const {author}=post
    console.log(author); */
    /*  return post */
    return new Promise((resolve, reject) => {

        setTimeout(() => {
            console.log('---------');
            if (post) {

                resolve(post)
            }
            else {
                reject()
            }


        }, 1000)
    }

    )
}
getPostById(1).then((data) => {
    console.log(data);
}).catch(() => {
    console.log("err");
})